package com.weijian.dal.enums;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum ImageStatusEnum {
    SUCCESS("成功", 0),
    FAIL("失败", 1),
    ENQUEUE("排队中", 2),
    PROCESSING("处理中", 3);


    private final String text;
    private final Integer value;

    ImageStatusEnum(String text, int value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据 value 获取枚举
     */
    public static ImageStatusEnum getEnumByValue(Integer value) {
        for (ImageStatusEnum item : values()) {
            if (Objects.equals(item.value, value)) {
                return item;
            }
        }
        return null;
    }

    /**
     * 根据 value 获取枚举 text
     */
    public static String getTextByValue(Integer value) {
        for (ImageStatusEnum item : values()) {
            if (Objects.equals(item.value, value)) {
                return item.text;
            }
        }
        return null;
    }
}
